<?php
/**
 * class App_Model_PaginationDataset
 *
 * @author kim
 */
class App_Model_PaginationDataset implements Iterator, Countable
{
    private $_index = 0;
    private $_data = array();
    private $_count = 0;

    function __construct($data, $count)
    {
        $this->_index = 0;
        $this->_data = $data;
        $this->_count = $count;
    }

    function __destruct()
    {
        unset($this->_data);
    }

    public function current()
    {
        return $this->_data[$this->_index];
    }

    public function key()
    {
        return $this->_index;
    }

    public function next()
    {
        return ++$this->_index;
    }

    public function rewind()
    {
        $this->_index = 0;
    }

    public function valid()
    {
        return isset($this->_data[$this->_index]) ? true : false;
    }

    public function count()
    {
        return $this->_count;
    }
}
